package com.yunyi.dm.factory.simple;


/**
 * 简单工厂类
 *
 * @author yunyi
 */
public class SimpleCoffeeFactory {
    public Coffee createCoffee(String type) {
        Coffee coffee = null;
        if ("american".equals(type)) {
            coffee = new AmericanCoffee();
        } else if ("latte".equals(type)) {
            coffee = new LatteCoffee();
        } else {
            throw new RuntimeException("没有咖啡");
        }
        return coffee;
    }

    public static Coffee createCoffeeStatic(String type) {
        Coffee coffee = null;
        if ("american".equals(type)) {
            coffee = new AmericanCoffee();
        } else if ("latte".equals(type)) {
            coffee = new LatteCoffee();
        } else {
            throw new RuntimeException("没有咖啡");
        }
        return coffee;
    }

}
